﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Threading;
using System.Globalization;
using Nivdal.AuxCode;

namespace Nivdal
{
    public partial class SearchForum : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
                Response.Redirect("Default.aspx");
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            OnlineUser ou = (OnlineUser)Session["User"];
            //this.Title = GND.ReturnAppTitle();
            this.Title = Resources.Resource.Default_PageTitle + ", " + Resources.Resource.SearchForum_PageTitle;

            if (ou.TeamId == "Null")
                Response.Redirect("~/GeneralMessage.aspx?MessageString=M74ggdizz5wfeh");
        }

        protected void ForumId_Click(object sender, EventArgs e)
        {
            this.SearchForumByIdSqlDataSource.SelectParameters.Clear();
            this.SearchForumByNameSqlDataSource.SelectParameters.Clear();
            this.ErrorLabel.Text = "";
            string ForumId = null;
            ForumId = this.ForumIdTextBox.Text.Trim();
            if (ForumId.Length == 0)
            {
                this.ErrorLabel.Text = Resources.Resource.SearchForum_EmptyForumIdErrorLabel;
            }
            else
            {
                this.SearchForumByIdGridView.Visible = true;
                this.SearchForumByIdSqlDataSource.SelectParameters.Add("ForumId", ForumId);
                this.SearchForumByNameGridView.Visible = false;
            }


        }
        protected void ForumName_Click(object sender, EventArgs e)
        {
            this.SearchForumByIdSqlDataSource.SelectParameters.Clear();
            this.SearchForumByNameSqlDataSource.SelectParameters.Clear();
            this.ErrorLabel.Text = "";
            string ForumName = null;
            ForumName = this.ForumNameTextBox.Text.Trim();
            if (ForumName.Length == 0)
            {
                this.ErrorLabel.Text = Resources.Resource.SearchForum_EmptyForumNameErrorLabel;
            }
            else
            {
                this.SearchForumByNameGridView.Visible = true;
                this.SearchForumByNameSqlDataSource.SelectParameters.Add("ForumName", ForumName);
                this.SearchForumByIdGridView.Visible = false;
            }


        }

        protected override void InitializeCulture()
        {
            OnlineUser ou = (OnlineUser)Session["User"];
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(ou.UICulture);
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ou.Culture);
        }
    }
}